<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:j="http://metalframework.org">
      
	<body>
		<ui:composition template="/WEB-INF/templates/template.xhtml">
			<ui:define name="content">
				<h2>Owner Information:</h2>
				<j:set value="#{clinic.getOwnerById(param.id)}" var="currentOwner" />
				
				<h:panelGrid columns="2">
					<h:column>
						<h:outputText value="Name" style="font-weight: bold;" />
					</h:column>
					<h:column>
						<h:panelGroup style="font-weight: bold;">
							<h:outputText value="#{currentOwner.firstName} #{currentOwner.lastName}" />
						</h:panelGroup>
					</h:column>
					<h:column>
						<h:outputText value="Address" style="font-weight: bold;" />
					</h:column>
					<h:column>
						<h:outputText value="#{currentOwner.address}" />
					</h:column>
					<h:column>
						<h:outputText value="City" style="font-weight: bold;" />
					</h:column>
					<h:column>
						<h:outputText value="#{currentOwner.city}" />
					</h:column>
					<h:column>
						<h:outputText value="Telephone" style="font-weight: bold;" />
					</h:column>
					<h:column>
						<h:outputText value="#{currentOwner.telephone}" />
					</h:column>
				</h:panelGrid>

				<br />
				<span class="submit">
					<h:outputLink value="edit-owner.xhtml">
						<f:param name="id" value="#{param.id}" />
						<h:outputText value="Edit Owner" />
					</h:outputLink>
				</span>

				<span class="submit">
					<h:outputLink value="edit-pet.xhtml">
						<f:param name="ownerId" value="#{param.id}" />
						<h:outputText value="Add New Pet" />
					</h:outputLink>
				</span>
				
				<h2>Pets and Visits:</h2>
				
				<ui:repeat value="#{currentOwner.pets}" var="currentPet">
					<h:panelGrid columns="2" width="100%">
						<h:column>
							<h:panelGrid columns="2">
								<h:column>
									<h:outputText value="Name" style="font-weight: bold;" />
								</h:column>
								<h:column>
									<h:outputText value="#{currentPet.name}" style="font-weight: bold;" />
								</h:column>
								<h:column>
									<h:outputText value="Birth Date" style="font-weight: bold;" />
								</h:column>
								<h:column>
									<h:outputText value="#{currentPet.birthDate}">
										<f:convertDateTime pattern="yyyy-MM-dd" />
									</h:outputText>
								</h:column>
								<h:column>
									<h:outputText value="Type" style="font-weight: bold;" />
								</h:column>
								<h:column>
									<h:outputText value="#{currentPet.type}" />
								</h:column>
							</h:panelGrid>
						</h:column>
						<h:column>
							<h:dataTable value="#{currentPet.visits}" var="currentVisit">
								<h:column>
									<f:facet name="header">Visit Date</f:facet>
									<h:outputText value="#{currentVisit.date}">
										<f:convertDateTime pattern="yyyy-MM-dd" />
									</h:outputText>
								</h:column>
								<h:column>
									<f:facet name="header">Description</f:facet>
									<h:outputText value="#{currentVisit.description}" />
								</h:column>
							</h:dataTable>
						</h:column>
					</h:panelGrid>

					<br />
					<span class="submit">
						<h:outputLink value="edit-pet.xhtml">
							<f:param name="ownerId" value="#{param.id}" />
							<f:param name="petId" value="#{currentPet.id}" />
							<h:outputText value="Edit Pet" />
						</h:outputLink>
					</span>
	
					<span class="submit">
						<h:outputLink value="edit-visit.xhtml">
							<f:param name="ownerId" value="#{param.id}" />
							<f:param name="petId" value="#{currentPet.id}" />
							<h:outputText value="Add Visit" />
						</h:outputLink>
					</span>
				</ui:repeat>
			</ui:define>
		</ui:composition>
	</body>
</html>
